package com.gxa.service.commlife.impl;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.gxa.entity.commlife.MerchantType;
import com.gxa.mapper.commlife.MerchantTypeMapper;
import com.gxa.service.commlife.MerchantTypeService;
import org.apache.commons.collections.map.HashedMap;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author yjl
 * @since 2022-10-12 11:18:00
 */
@Service
public class MerchantTypeServiceImpl extends ServiceImpl<MerchantTypeMapper, MerchantType> implements MerchantTypeService {
    @Autowired
    private MerchantTypeMapper merchantTypeMapper;

    @Override
    public int  addMerchantTypeMapper(MerchantType merchantType){
        int insert = this.merchantTypeMapper.insert(merchantType);
        return insert;
    }

    @Override
    public void updateMerchantType(MerchantType merchantType) {
        this.merchantTypeMapper.updateById(merchantType);
    }

    @Override
    public void deleteMerchantType(Integer id) {
        this.merchantTypeMapper.deleteById(id);
    }

    @Override
    public MerchantType queryById(int id) {
        MerchantType merchantType = this.merchantTypeMapper.selectById(id);
        return merchantType;
    }

    @Override
    public List<MerchantType> searchMerchantType(MerchantType merchantType) {
        return null;
    }

    @Override
    public Map<String,Object> queryList(String typeName,Integer pageNum, Integer pageSize) {
        Map<String,Object> map = new HashedMap();
        QueryWrapper<MerchantType> queryWrapper = new QueryWrapper();
        queryWrapper.likeRight("type_name",typeName);
        Page<MerchantType> page = PageHelper.startPage(pageNum, pageSize);
        List<MerchantType> merchantTypeList = this.merchantTypeMapper.selectList(queryWrapper);
        PageInfo<MerchantType> pageInfo = new PageInfo<>(merchantTypeList);
        map.put("pageInfo",pageInfo);
        return map;
    }

    @Override
    public List<MerchantType> queryList1() {
        QueryWrapper<MerchantType> queryWrapper = new QueryWrapper();
        List<MerchantType> merchantTypeList = this.merchantTypeMapper.selectList(queryWrapper);
        return merchantTypeList;
    }


}
